package com.triumphxx.langchain4j.Config;

import dev.langchain4j.model.openai.OpenAiChatModel;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

/**
 * @author:triumphxx
 * @Date: 2025/7/24
 * @Time: 14:08
 * @微信公众号：思考集结处
 * @网站：http://blog.triumphxx.com.cn
 * @GitHub https://github.com/triumphxx
 * @Desc: ds配置
 **/
@Configuration
@Getter
public class DeepSeekConfig {
    @Value("${deepseek.apiKey}")
    private String apiKey;

    @Value("${deepseek.model}")
    private String modelName;

    @Value("${deepseek.baseUrl}")
    private String baseUrl;

    @Value("${deepseek.temperature}")
    private Double temperature;

    @Value("${deepseek.maxToken}")
    private Integer maxTokens;

    @Bean
    public OpenAiChatModel openAiChatModel() {
        return OpenAiChatModel.builder()
                .apiKey(apiKey)
                .modelName(modelName)
                .baseUrl(baseUrl)
                .temperature(temperature)
                .maxTokens(maxTokens)
                .timeout(Duration.ofSeconds(60))
                .logRequests(true)
                .logResponses(true)
                .build();
    }
}
